if("WebSocket" in window){
    console.log("this browser supports websocket...");
    var webSocket=new WebSocket("ws://localhost:8081/webSocket");
}else{
    console.log("this browser does not supports websocket...");
}
webSocket.onerror=function(){
    console.log("链接错误...");
}
webSocket.onopen=function(){
    console.log("链接成功...");
}

/*
 * 哪个页面使用哪个页面加
 * webSocket.onmessage=function(event){
   alert(event);
}*/
webSocket.onclose=function(){
    console.log("链接关闭...");
}
window.onbeforeunload=function(){
    console.log("窗口即将关闭，准备关闭链接...");
    webSocket.close();
}
function webSend(){
    webSocket.send(decodeURIComponent($("#form1").serialize(),true));
}
function SendMesaage(mes){
    webSocket.send(mes);
}
var closeConn=function(){
    webSocket.close();
}